package com.dc.adaptor.container;

import java.util.LinkedList;
import java.util.List;

import com.dc.adaptor.Adaptor;
import com.dc.adaptor.InputAdaptor;
import com.dc.adaptor.OutputAdaptor;

public class AdaptorContainer {
	
	private static List<InputAdaptor> listIn = new LinkedList<InputAdaptor>();
	
	private static List<OutputAdaptor> listOut = new LinkedList<OutputAdaptor>();
	
	public static synchronized void  register(Adaptor adaptor){
		if(adaptor instanceof InputAdaptor){
			listIn.add((InputAdaptor)adaptor);
		}else if(adaptor instanceof OutputAdaptor){
			listOut.add((OutputAdaptor)adaptor);
		}else{
			throw  new RuntimeException("Unknown adaptor "+adaptor.getClass());
		}
		
	}	
	public static synchronized void remove(Adaptor adaptor){
		if(adaptor instanceof InputAdaptor){
			listIn.remove(adaptor);
		}else if(adaptor instanceof OutputAdaptor){
			listIn.remove(adaptor);
		}else{
			throw  new RuntimeException("unknown instanceof adaptor");
		}
		
	}
	
	public static List<InputAdaptor> getInputAdaptors(){
		return listIn;
	}
	
	public static List<OutputAdaptor> getOutputAdaptors(){
		return listOut;
	}
	
}
